From: Sebastian Wick Date: Wed, 6 Aug 2025 08:54:04 +0000 (+0200) Subject: brightnessManager: Handle backlights with limited number of steps X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~112^2^2~9 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ebc850381818ab9f8dda6a463531ff3727066fad;p=gnome-shell.git brightnessManager: Handle backlights with limited number of steps Adjusts how many steps a BrightnessScale has to ensure that every stepUp/stepDown results in a visible change. Part-of: --- diff --git a/js/misc/brightnessManager.js b/js/misc/brightnessManager.js index a0402b9b4..23cd147d7 100644 --- a/js/misc/brightnessManager.js +++ b/js/misc/brightnessManager.js @@ -161,7 +161,12 @@ export const BrightnessManager = GObject.registerClass({ if (monitors.length === 0) { this._globalScale = null; } else if (!this._globalScale) { - this._globalScale = new BrightnessScale(_('Brightness'), 1.0); + // Handle scales with just a few steps + const maxSteps = Math.max(...[...this._monitorScales.values()] + .map(s => s.nSteps)); + const nSteps = Math.min(maxSteps, SCALE_VALUE_N_STEPS); + + this._globalScale = new BrightnessScale(_('Brightness'), 1.0, nSteps); this._globalScale.connect('notify::value', () => { if (this._inhibitUpdates) return; @@ -341,7 +346,16 @@ const MonitorBrightnessScale = GObject.registerClass({ constructor(monitor, value = 1.0) { const name = monitor.get_monitors()[0].get_display_name(); - super(name, value); + // Handle backlights with just a few steps + const maxSteps = Math.max(...monitor.get_monitors() + .filter(m => m.get_backlight() && m.is_active()) + .map(m => { + const b = m.get_backlight(); + return b.brightnessMax - b.brightnessMin; + })); + const nSteps = Math.min(maxSteps, SCALE_VALUE_N_STEPS); + + super(name, value, nSteps); this._monitor = monitor; this._currentBacklightBrightness = -1;